#!/usr/local/bin/python3
# -*- coding: UTF-8 -*-
from Core.exportNodesFile import exportNodesFile
from Common.stringManage import splitStringByIndex
from Common.stringManage import splitString
import sys
import os
import json

import shutil
import zipfile
import time

def makeNodesFile(out,zip,productName):
        outPath=out
        zipPath=[0 for i in range(0, len(zip))]
        
        for i in range(0, len(zip)):
                print("参数", i, zip[i])
                zipPath[i]=zip[i]
        print(zipPath)
        
        for i in range(0, len(zipPath)):
                unZipPath = splitStringByIndex(zipPath[i],".zip",0)
                # print("路径", unZipPath)
                jsonPath=splitString(unZipPath,"/")
                jsonPath=splitStringByIndex(jsonPath,"_",0)
                jsonPath=unZipPath+"/"+jsonPath+".json"
                template=exportNodesFile(unZipPath,zipPath[i])   
               
                template.unZip()
                luaName="Makeup"+str(i+1)
                inNodePath=unZipPath+"/"+luaName
                
                template.loadjson(jsonPath,luaName,outPath,productName)
                template.copyLuaFile(inNodePath,outPath+"/")

                template.copyRescource(inNodePath,outPath+"/"+luaName)
